package nullby.yoga.adapter;

import java.util.List;

import nullby.yoga.R;
import nullby.yoga.bo.Song;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

public class SongAdapter extends ArrayAdapter<Song> {
	private List<Song> objects;
	private LayoutInflater inflater;
	private Boolean mark;

	public SongAdapter(Context context, int textViewResourceId,
			List<Song> objects, Boolean mark) {
		super(context, textViewResourceId, objects);
		this.objects = objects;
		this.mark = mark;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View vi, ViewGroup parent) {
		if (vi == null) {
			vi = inflater.inflate(R.layout.song_item, null);
		}

		// ImageView iv = (ImageView) vi.findViewById(R.id.ivSongIcon);
		// iv.setImageResource(getContext().getResources().getIdentifier(
		// objects.get(position).getIcon(), "drawable",
		// getContext().getPackageName()));
		// iv.setPadding(0, 0, 20, 0);
		CheckedTextView tt = (CheckedTextView) vi
				.findViewById(R.id.tvSongTitle);
		tt.setText(objects.get(position).getTitle());
		// if (mark) {
		tt.setChecked(objects.get(position).getCheck());
		// } else {
		// tt.setCheckMarkDrawable(null);
		// }

		vi.setPadding(20, 10, 20, 10);
		return vi;
	}

}
